﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using HitachiLib.Utils;
using HitachiLib.Data;
using HitachiLib.HitachiServiceRef;

namespace HitachiApp.Model.Resources
{
    public class ResourceManageItem : INotifyPropertyChanged
    {
        private bool selected = false;
        public bool Selected
        {
            get { return selected; }
            set { selected = value; }
        }

        private Resource data;
        private String new_password;

        public String NewPassword
        {
            get { return new_password; }
            set { new_password = value; }
        }
        public Resource Data
        {
            get { return data; }
            set { data = value; }
        }
        private ObservableCollection<ResourceManageItem> children = new ObservableCollection<ResourceManageItem>();
        private ResourceManageItem parent = null;
        public ObservableCollection<ResourceManageItem> Children
        {
            get { return children; }
            set { children = value; }
        }
        public ResourceManageItem Parent
        {
            get { return parent; }
            set { parent = value; }
        }
        public String Name
        {
            get
            {
                ResourceData rd = data.Data;
                return rd.Name + " - " + rd.WorkID;
            }
        }

        public void ClearSelected()
        {
            Selected = false;
            foreach (ResourceManageItem rmi in children)
            {
                rmi.ClearSelected();
            }
            RaisePropertyChanged("Selected");
        }

        #region PropertChanged Block
        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }
        #endregion
    }
}
